package cn.tedu.admin.companyandjob.dao.persist.repository.impl;

import cn.tedu.admin.companyandjob.dao.persist.mapper.CompanyMapper;
import cn.tedu.admin.companyandjob.dao.persist.repository.ICompanyRepository;
import cn.tedu.admin.companyandjob.pojo.entity.CompanyDetail;
import cn.tedu.admin.companyandjob.pojo.vo.CompanyListItemVO;
import cn.tedu.common.pojo.vo.PageData;
import cn.tedu.common.util.PageInfoToPageDataConverter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CompanyRepository implements ICompanyRepository {
    @Autowired
    CompanyMapper companyMapper;


    @Override
    public PageData<CompanyListItemVO> selectList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<CompanyListItemVO> list = companyMapper.selectList();
        PageInfo<CompanyListItemVO> pageInfo = new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }

    @Override
    public void updataCompany(CompanyDetail companyDetail) {
        companyMapper.updateById(companyDetail);
    }

    @Override
    public void deleteCompany(Long companyId) {
        companyMapper.deleteById(companyId);
    }


}
